home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 …ember: Reference Library / Apple Developer Reference Library (December 1999) (Disk 1).iso / pc / technical documentation / develop / develop issue 28 / develop issue 28 code / macapp debugging / twistdownlists / utwistdownglobals.h < prev    next >
Encoding:
Text File  |  1996-07-15  |  14.8 KB  |  382 lines

  1. //----------------------------------------------------------------------------------------
  2. // UTwistDownGlobals.h
  3. // ETO20 MacApp 3.3.1, MPW 3.4.1
  4. // Copyright ©1994-1996 Conrad Kopala
  5. // Twist Down Lists version 2.0a0 7/15/96
  6. //----------------------------------------------------------------------------------------
  7. #ifndef __UTWISTDOWNGLOBALS__
  8. #define __UTWISTDOWNGLOBALS__
  9.  
  10. #ifndef __UTWISTDOWNAPP__
  11. #include "UTwistDownApp.h"
  12. #endif
  13.  
  14. //MacApp stuff
  15. #ifndef __UMACAPPGLOBALS__
  16. #include "UMacAppGlobals.h"
  17. #endif
  18.  
  19. #ifndef __UERRORMGR__
  20. #include "UErrorMgr.h"    //to get value for messageLookup
  21. #endif
  22.  
  23. #ifndef __UFAILURE__
  24. #include "UFailure.h"
  25. #endif
  26.  
  27. //ToolBox stuff
  28. //None
  29.  
  30. //ANSI stuff
  31. //None
  32.  
  33. // My programs always include an AppGlobals.h file and an AppGlobals.r file. 
  34. // The first part of the AppGlobals.h file parallels the AppGlobals.r file. 
  35. // These two files define all command numbers, menu IDs, resource IDs, etc.
  36. // This approach to organizing program files arose out of development scenarios 
  37. // involving multiple cooperative programs that share common files. 
  38. // With it, I do not have to search through files to find these things 
  39. // because I know where they are going to be defined. The risk of duplication and 
  40. // confusion is minimized. For example, it is less likely with this approach that 
  41. // something like kDefaultOKItemID will be defined more than once.
  42.  
  43. //The following are also defined in TwistDownGlobals.r
  44. //----------------------------------------------------------------------------------------
  45. // Finder stuff
  46. //----------------------------------------------------------------------------------------
  47. const OSType kSignature                            = 'TDL%';
  48. const OSType kFileType                             = 'disk';
  49. const OSType kAETwistDownListsSuite    = 'TDL%';    //AppleEvent class for TwistDownLists scripting support
  50. //----------------------------------------------------------------------------------------
  51. // AboutBoxIcon ID
  52. //----------------------------------------------------------------------------------------
  53. const ResNumber kAboutBoxIcon    = 2000;
  54.  
  55. //----------------------------------------------------------------------------------------
  56. // Menu IDs.
  57. //----------------------------------------------------------------------------------------
  58.  
  59. const ResNumber mFormatMenu            = 4;
  60. const ResNumber mControlMenu        = 5;
  61. const ResNumber mWindowsMenu        = 6;
  62. #if qDebug
  63. const ResNumber mTestMenu                = 7;
  64. #endif
  65. const ResNumber mFontMenu                = 8;
  66.  
  67. //----------------------------------------------------------------------------------------
  68. // Command numbers For Menu Items
  69. //----------------------------------------------------------------------------------------
  70.  
  71. const CommandNumber cExpandAll                        =    1000;    //menu command number
  72. const CommandNumber cCollapseAll                    =    1001;    //menu command number
  73. const CommandNumber cShowInvisibleFiles        =    1002;    //menu command number
  74. const CommandNumber cFailHere                            = 1003;    //menu command number
  75. const CommandNumber cAllowUnlimitedDocs        = 1004;    //menu command number
  76.  
  77. const CommandNumber cAppleEventRouting            = 1100;    //menu command number for toggle between SendToDoc and SendToView
  78. const CommandNumber cSendAppleEvents                = 1101;    //menu command number
  79.  
  80. const CommandNumber cWritingDirection                = 1110;    //menu command number for toggle between LeftToRight and RightToLeft
  81. const CommandNumber cUseSystemDirection            = 1111;    //menu command number
  82.  
  83. const CommandNumber cChangeWritingDirection    = 1112;    //used as common command number for TChangeWritingDirectionCommand
  84.  
  85. //Change Font commands
  86. const CommandNumber  cFont                    = 1750;    //Font menu item & is for hierarchical sub-menu
  87. const CommandNumber  cChangeFont         = 1751;    //used as common command number for TChangeFontCommand
  88.  
  89. //Change Font-size commands
  90. const CommandNumber  cLargerFontSize        = 1761;    //menu command number
  91. const CommandNumber  cSmallerFontSize     = 1762;    //menu command number
  92. const CommandNumber  cOtherFontSize         = 1763;    //menu command number
  93.  
  94. const CommandNumber  cChangeFontSize         = 1764;    //used as common command number for TChangeFontSizeCommand
  95.  
  96. const CommandNumber  cFontSizeBase            = 1800;
  97. const CommandNumber  cFontSizeMin                = 1809;
  98. const CommandNumber  cFontSizeMax                = 1896;
  99.  
  100. #if qDebug
  101. const CommandNumber cCountObjects                        = 1901;    //menu command number
  102. const CommandNumber cResetObjectCount                = 1902;    //menu command number
  103. const CommandNumber cPrintBaseClassInfo            = 1903;    //menu command number
  104. const CommandNumber cPrintMacAppClassInfo        = 1904;    //menu command number
  105. const CommandNumber cPrintAppClassInfo            = 1905;    //menu command number
  106. const CommandNumber cAppUserFlag1                        = 1906;    //menu command number
  107. const CommandNumber cAppUserFlag2                        = 1907;    //menu command number
  108. const CommandNumber cAppUserFlag3                        = 1908;    //menu command number
  109. #endif
  110.  
  111. //--------------------------------------------------------------------------------------------------
  112. // Other Command Numbers
  113. //--------------------------------------------------------------------------------------------------
  114.  
  115. const CommandNumber  cSplashScreen            = 1950;
  116. const CommandNumber  cExpandElement            = 1951;
  117. const CommandNumber  cCollapseElement        = 1952;
  118. const CommandNumber  cSetSearchMethod      = 1953;    //Required for TTwistDownDocument::GetSetPropertyInfo
  119. //--------------------------------------------------------------------------------------------------
  120. //    AppleEvents for scripting support
  121. //--------------------------------------------------------------------------------------------------
  122. const ResNumber kTDLAEDispatchTable = 1000;        //aedt resource
  123.  
  124. //AppleEvent event IDs
  125. const OSType kAEExpandAllID                                = 'exAL';        // cExpandAll    
  126. const OSType kAECollapseAllID                            = 'clAL';        // cCollapseAll
  127. const OSType kAEExpandElementID                        = 'exLI';        // cExpandElement
  128. const OSType kAECollapseElementID                    = 'clLI';        // cCollapseElement
  129.  
  130. #if qDebug
  131. const OSType kAEResetObjectCountID                = 'rsOC';        // cResetObjectCount
  132. #endif
  133.  
  134. enum 
  135. {
  136.     cTwistDownView                = 'TDvw',    //class definition for the TTwistDownView
  137.     cTwistDownElement            = 'TDel'    //class definition for the TTwistDownElement
  138. };
  139.  
  140. enum
  141. {
  142.     enumWritingDirection    =    'WDir',
  143.     kAELeftToRight                =    'ltRT',
  144.     kAERightToLeft                =    'rtLT'
  145. };
  146.  
  147. //Search method for finding things in the list
  148. enum
  149. {
  150.     enumSearchMethod    =    'SMth',
  151.     kAEVisibleList        =    'SVli',
  152.     kAEWholeList            =    'SWli'
  153. };
  154.  
  155. //Apple Event routing
  156. enum
  157. {
  158. enumAERouting            = 'EAEr',
  159. kAERouteToDoc            = 'RDoc',
  160. kAERouteToView        = 'RVew'
  161. };
  162.  
  163. //properties of TTwistDownApp
  164. enum {
  165.     pShowInvisibleFiles     = 'SHin',
  166.     pUseSystemDirection     = 'usSD',
  167.     pSendAppleEvents            = 'snAE',
  168.     pFailHere                            = 'FlHr',
  169.     pAERouting                        =    'AERt',
  170.     pUnlimitedDocs                = 'ULDs'
  171.     #if qDebug
  172.     ,
  173.     pObjectCountingEnabled    = 'cObj',
  174.     pPrBaseClassInfo                = 'prBC',
  175.     pPrMacAppClassInfo            = 'prMA',
  176.     pPrAppClassInfo                    = 'prAp',
  177.     pSetAppUserFlag1                = 'sUF1',
  178.     pSetAppUserFlag2                = 'sUF2',
  179.     pSetAppUserFlag3                = 'sUF3'
  180.     #endif
  181. };
  182.     
  183. //properties of TTwistDownDocument
  184. enum {
  185.     pNumFolders                    = 'Nfld',            // number of folders in the twist down list
  186.     pNumFiles                        = 'Nfil',            // number of files in the twist down list
  187.     pNumItems                        = 'Nitm',            // sum of number of folders and number of files in the twist down list
  188.     pSearchMethod                = 'SMTH'
  189. };
  190.  
  191. //properties of TTwistDownView
  192. enum {
  193.     pWritingDirection                = 'wDir',
  194.     keyAEWritingDirection        = 'wDIR',
  195.     pCouldExpand                      = 'CDex',            // fCouldExpand
  196.     pCouldCollapse                  = 'CDcl',            // fCouldCollapse    
  197.     pFontName                              = 'fntN'        
  198. };
  199.  
  200. //Properties for TTwistDownElement
  201. enum {
  202.     pHasSubList                    = 'hsSL',        //
  203.     pShowSubList                = 'shSL',        //
  204.     pHasControl                    = 'hsCT',        //
  205.     pItemInList                    = 'liTM',        //Absolute position in the list
  206.     pIndentLevel                = 'INDT'    
  207. };
  208.  
  209. //----------------------------------------------------------------------------------------
  210. // Menu Items name str resource stuff for toggled commands
  211. //----------------------------------------------------------------------------------------
  212. const ResNumber kMenuNameStrings        = 9999;
  213.  
  214. //----------------------------------------------------------------------------------------
  215. // Menu Items name indices for toggled commands
  216. //----------------------------------------------------------------------------------------
  217. const    short kLeftToRightNameIdx     = 1;
  218. const    short kRightToLeftNameIdx     = 2;
  219. const    short kRouteToDocNameIdx         = 3;
  220. const    short kRouteToViewNameIdx     = 4;
  221.  
  222. //----------------------------------------------------------------------------------------
  223. // Window and view resource IDs.
  224. //----------------------------------------------------------------------------------------
  225.  
  226. const IDType kTwistDownViewID                     = 'SYVW';
  227. const IDType kChangeFontSizeViewID             = 'SIZE';
  228. const IDType kSizeValueViewID                         = 'fsvl';
  229. const IDType kProgressViewID                        = 'prog';
  230. const IDType kProgressOperationViewID        = 'Oper';
  231. const IDType kProgressSubjectViewID            = 'Vol '; 
  232. const IDType kProgressBarViewID                    = 'pBar';
  233. const IDType kAboutProgNameViewID                = 'pNam';    //TStaticText ID for Program name in the about box
  234. const IDType kAboutCopyrightViewID            = 'cprt';    //TStaticText ID for copyright in the about box
  235.  
  236. const IDType kTwistDownControlViewID        =    'TDct';    //Not really needed but useful when debugging
  237.                                                                                                     //because it allows you to identify a twistDowncontrol.
  238.  
  239. const ResNumber kAboutBoxWindowID                = 2000;
  240. const ResNumber kTwistDownWindowID             = 2002;
  241. const ResNumber kChangeFontSizeWindowID = 2003;
  242. const ResNumber kProgressWindowID                = 2004;
  243.  
  244. //----------------------------------------------------------------------------------------
  245. //Balloon help stuff.
  246. //----------------------------------------------------------------------------------------
  247. const ResNumber kChangeFontSizeDialogHelp        = 3006;
  248. const ResNumber kTwistDowncontrolHelp                = 3011;
  249. const ResNumber kProgressDialogHelp                 = 5001;
  250.  
  251. const ResNumber kAppIconHelpStrings                             = 3000;
  252. const ResNumber kTDLMenuHelpStrings                             = 3001;
  253. const ResNumber kFormatMenuHelpStrings                         = 3002;
  254. const ResNumber kFontMenuHelpStrings                             = 3003;
  255. const ResNumber kSizeMenuHelpStrings                             = 3004;
  256. const ResNumber kWindowsMenuHelpStrings                     = 3005;
  257. const ResNumber kChangeFontSizeDialogHelpStrings    = 3006;
  258. const ResNumber kWritingDirectionHelpStrings            = 3007;
  259. const ResNumber kControlMenuHelpStrings                        = 3008;
  260. const ResNumber kAppleEventsHelpStrings                        = 3009;
  261.  
  262. #if qDebug
  263. const ResNumber kTestMenuHelpStrings                            = 3010;
  264. #endif
  265. const ResNumber kTwistDownControlHelpStrings            = 3011;
  266. const ResNumber kProgressDialogHelpStrings                 = 5001;
  267.  
  268. //----------------------------------------------------------------------------------------
  269. //    Error information.
  270. //----------------------------------------------------------------------------------------
  271. const ResNumber kErrorStrings            = 6001;
  272. const long msgNotHFSVolume = messageLookup + -26002;
  273. const short errNotHFSVolume    = -26002;
  274.  
  275. const long msgAENotAFolder = messageLookup + -26003;
  276. const short errAENotAFolder    = -26003;
  277.  
  278. const long msgTooManyRows     = messageLookup + -26004;
  279. const short errTooManyRows = -26004;
  280.  
  281. const long msgCantExpandElement    = messageLookup + -26005;
  282. const short errCantExpandElement = -26005;
  283.  
  284. const long msgListAlreadyExpanded    = messageLookup + -26006;
  285. const short errListAlreadyExpanded = -26006;
  286.  
  287. const long msgListAlreadyCollapsed = messageLookup + -26007;
  288. const short errListAlreadyCollapsed    = -26007;
  289.  
  290. const long msgElementAlreadyExpanded = messageLookup + -26008;
  291. const short errElementAlreadyExpanded    = -26008;
  292.  
  293. const long msgElementAlreadyCollapsed    = messageLookup + -26009;
  294. const short errElementAlreadyCollapsed    = -26009;
  295.  
  296. const long msgFailHere    = messageLookup + -26010;
  297. const short errFailHere    = -26010;
  298. //----------------------------------------------------------------------------------------
  299. //    Other Constants #1
  300. //----------------------------------------------------------------------------------------
  301. const IDType kDefaultOKItemID        = 'ok  ';
  302. const IDType kCancelItemID            = 'cncl';
  303. const IDType kStopItemID                = 'stop';
  304.  
  305. //End of items that are also defined in TwistDownGlobals.r
  306. //----------------------------------------------------------------------------------------
  307. //    Other Constants #2
  308. //----------------------------------------------------------------------------------------
  309. const Boolean kHasSplashScreen     = TRUE;
  310. const Boolean kHasAboutBox             = TRUE;    //not used yet
  311. const Boolean kForSplashScreen     = TRUE;
  312. const Boolean kForAboutBox            = !kForSplashScreen;
  313.  
  314. const short kTriangleOutsideGap = 1;
  315. const short kTriangleInsideGap     = 2;
  316.  
  317. //The following constant is used to set the number of rows that TTextListView
  318. //will display. To test failure handling for the maximum number of rows that
  319. //can be displayed, set it to some small value. It can never be larger than kMaxShort;
  320. //Note that the object heap would have to expand to over 10mb in order to fill
  321. //TTextListView.
  322. const short kMaxNumberOfItemsToDisplay        = kMaxShort;
  323. //----------------------------------------------------------------------------------------
  324. // Version stuff for the About Box
  325. //----------------------------------------------------------------------------------------
  326. const ResType     kVersInfoType        = 'vers';
  327. const ResNumber kVers1InfoID        = 1;
  328.  
  329. //----------------------------------------------------------------------------------------
  330. //    Event Numbers.
  331. //----------------------------------------------------------------------------------------
  332. const short mExpandElement             = 1000;
  333. const short mCollapseElement         = 1001;
  334. const short mUpdateProgressBar    = 1002;
  335.  
  336. //----------------------------------------------------------------------------------------
  337. //    For Script.h support.
  338. //----------------------------------------------------------------------------------------
  339. enum EWritingDirection
  340. {
  341.     leftToRight                = 0,
  342.     rightToLeft                = 1
  343. };
  344.  
  345. enum EAppleEventRouting
  346. {
  347.     routeToDoc                = 0,
  348.     routeToView                = 1
  349. };
  350.  
  351. enum ESearchMethod
  352. {
  353.     visibleList            = 0,
  354.     wholeList                = 1
  355. };
  356.  
  357. //----------------------------------------------------------------------------------------
  358. // For object heap size management
  359. //----------------------------------------------------------------------------------------
  360. const long kFreeMemReserve = 300*1024;
  361. //----------------------------------------------------------------------------------------
  362. // externals
  363. //----------------------------------------------------------------------------------------
  364.  
  365. extern FileFilterYDProcPtr gFileFilterYDProcPtr;
  366. extern DlgHookYDProcPtr gDlgHookYDProcPtr;
  367.  
  368. //In a normal application the following three globals would be #if qDebug
  369. extern Boolean gFailHere;
  370. extern Boolean gSendAppleEvents;
  371. extern Boolean gUseSystemDirection;
  372. extern EAppleEventRouting gAppleEventRouting;
  373. //----------------------------------------------------------------------------------------
  374. // Globals functions defined in this unit.
  375. //----------------------------------------------------------------------------------------
  376.  
  377. pascal Boolean MyCustomFileFilter(CInfoPBPtr PB, void *yourDataPtr);
  378. pascal short MyCustomDlgHook(short item, DialogPtr theDialog, void *yourDataPtr);
  379.  
  380. short InitMaxObjectHeapSize();
  381. Boolean HaveObjectHeapSpace(long amountRequired);
  382. #endif